<template>
	<view>
		<u-navbar  :title="info.name + '的资料'" :autoBack="true" safeAreaInsetTop fixed placeholder />
		<uni-card  title="基本信息" padding="0">
			<view>
				<u-cell-group>
					<u-cell center :arrow="false" title="姓名">
						<view class="u-font-md text-black" slot="value">{{info.name}}</view>
					</u-cell>
					
					<u-cell center :arrow="false" title="手机号码">
						<view class="u-font-md text-black" slot="value">{{info.tel}}</view>
					</u-cell>
					
					<u-cell center :arrow="false" title="性别">
						<view class="u-font-md text-black" slot="value">
							<dict-tag :type="userSex" :value="info.gender" />
						</view>
					</u-cell>
					
					<u-cell center :arrow="false" title="年龄">
						<view class="u-font-md text-black" slot="value">{{info.grade}}</view>
					</u-cell>
					
					<u-cell center  :arrow="false" title="生日">
						<view class="u-font-md text-black" slot="value">{{this.$common.timeFormat(info.birthday, 'yyyy年MM月dd日')}}</view>
					</u-cell>
					
					<u-cell center :arrow="false" title="类型">
						<view class="u-font-md text-black" slot="value">
							<dict-tag :type="studentStage" :value="info.stage" />
						</view>
					</u-cell>
					
					<u-cell center :arrow="false" title="备注">
						<view class="u-font-md text-black" slot="value">{{info.remark?info.remark:""}}</view>
					</u-cell>
				</u-cell-group>
			</view>
		</uni-card>
		
		<uni-card  title="报名的课程" padding="0">
			<view v-if="courseList.length > 0" >
				<view v-for="(item,index) in courseList" :key='index'>
					<u-cell-group>
						<u-cell  center :is-link="false" :arrow="false" @click="studentdetail(item.id)">
							<view slot="title">{{item.courseName}}</view>
							<view slot="label" class="line-height-view">学习进度 {{item.countLessonComplete}} / {{item.countLessonTotal}}</view>
							<view slot="label" class="line-height-view">有效期 {{item.expireDate}}</view>
							<view slot="label" class="line-height-view">剩余: {{item.countLessonRemaining||0}}次</view>
						</u-cell>
					</u-cell-group>
				</view>
			</view>
			
			<view class="u-padding-30 bg-white" v-else="courseList.length == 0" >
				<u-empty mode="list" text="暂无报名课程"></u-empty>
			</view>
	    </uni-card>
	</view>
</template>
<script>
	import request from '@/utils/request'
	import { parseTime } from "@/utils/zhanpeng.js"
	export default {
		data() {
			return {
				info: {},
				studentStage: this.$dictType.STUDENT_STAGE,
				userSex: this.$dictType.SYSTEM_USER_SEX,
				courseList: [],
			}
		},
		onLoad(option) {
			this.studentId = option.studentId
			this.getInfo()
			//this.getCourseList()
		},
		methods: {
			getInfo() {
				request({url:'/erp/student/get', data:{
					id: this.studentId
				}}).then(res => {
					if (!this.$common.handleResponseMsg(res)) return;
					this.info = res.data
				});
			},
			getCourseList() {
				request({url:'/erp/student/courseStats',data: {
					studentId: this.studentId
				}}).then(res => {
					if (!this.$common.handleResponseMsg(res)) return;
					this.courseList = res
				});
			},
			clickLeft() {
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ededed;
	}
	
	.line-height-view {
		line-height: 28px;
		height: 28px;
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.user-box {
		background-color: #fff;
	}
</style>
